<?php

    class Articlem extends CI_Model{

        function __construct(){
            parent::__construct();
        }

        function list_own($condition=NULL){
            
            if($condition==NULL) {
                
                //$condition = array('article.user_id'=>$this->session->userdata('id'));
                //$condition = array('article.user_id'=>$this->session->userdata('id') ,'article.status !='=>0);
                
            }
           
             
            $this->db->select('article.id as article_id'); 
            $this->db->select('article.datepublish as article_datepublish'); 
            $this->db->select('article.datepublishend as article_datepublishend'); 
            $this->db->select('article.datepublishhalf as article_datepublishhalf'); 
            $this->db->select('article.datepublishendhalf as article_datepublishendhalf'); 
            $this->db->select('article.title as article_title'); 
            $this->db->select('article.uptitle as article_uptitle'); 
            $this->db->select('article.intro as article_intro'); 
            $this->db->select('article.text article_text'); 
            $this->db->select('article.status article_status'); 
            $this->db->select('article.priority article_priority'); 
            $this->db->select('article.user_id article_user_id'); 
            $this->db->select('articlemedia.article_id as articlemedia_article_id'); 
            $this->db->select('articlemedia.media_id as articlemedia_media_id'); 
            $this->db->select('media.id as media_id'); 
            $this->db->select('media.type as media_type'); 
            $this->db->select('media.filepath as media_filepath');
            
            $this->db->from('article', 'articlemedia','media');
            
            //$this->db->where($condition);
            
            $this->db->join('articlemedia', 'articlemedia.article_id = article.id');
            $this->db->join('media', 'media.id = articlemedia.media_id');
            
            $this->db->order_by('article.id','desc');

            $res = $this->db->get()->result_array();
            
            $this->firephp->fb('last:'.$this->db->last_query()); 
            
            return $res; 
            
            
            
            
        }
        
        function art_id($id){
            
            $this->db->select('article.id as article_id'); 
            $this->db->select('article.datepublish as article_datepublish'); 
            $this->db->select('article.datepublishend as article_datepublishend'); 
            $this->db->select('article.datepublishhalf as article_datepublishhalf'); 
            $this->db->select('article.datepublishendhalf as article_datepublishendhalf'); 
            $this->db->select('article.title as article_title'); 
            $this->db->select('article.uptitle as article_uptitle'); 
            $this->db->select('article.intro as article_intro'); 
            $this->db->select('article.text article_text'); 
            $this->db->select('article.status article_status'); 
            $this->db->select('article.priority article_priority'); 
            $this->db->select('article.user_id article_user_id'); 
            $this->db->select('articlemedia.article_id as articlemedia_article_id'); 
            $this->db->select('articlemedia.media_id as articlemedia_media_id'); 
            $this->db->select('media.id as media_id'); 
            $this->db->select('media.type as media_type'); 
            $this->db->select('media.filepath as media_filepath'); 
            
            $this->db->from('article', 'articlemedia','media');
            
            $this->db->where(array('article.id'=>$id));
            
            $this->db->join('articlemedia', 'articlemedia.article_id = article.id');
            $this->db->join('media', 'media.id = articlemedia.media_id');
            
            $this->db->order_by('article.id','desc');

            $res = $this->db->get()->result_array();
            
            $this->firephp->fb('last:'.$this->db->last_query()); 
            
            return $res; 
                        
        }

    }

?>
